package com.mazaiting.redeye.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mazaiting.redeye.interfaces.IJsonBean;
import com.mazaiting.redeye.utils.JackJsonUtil;

import java.util.List;

/***
 *
 *
 *                                                    __----~~~~~~~~~~~------___
 *                                   .  .   ~~//====......          __--~ ~~
 *                   -.            \_|//     |||\\  ~~~~~~::::... /~
 *                ___-==_       _-~o~  \/    |||  \\            _/~~-
 *        __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *    _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *  .~       .~       |   \\ -_    /  /-   /   ||      \   /
 * /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 * |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *          '         ~-|      /|    |-~\~~       __--~~
 *                      |-~~-_/ |    |   ~\_   _-~            /\
 *                           /  \     \__   \/~                \__
 *                       _--~ _/ | .-~~____--~-/                  ~~==.
 *                      ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                 -_     ~\      ~~---l__i__i__i--~~_/
 *                                 _-~-__   ~)  \--______________--~~
 *                               //.-~~~-~_--~- |-------~~~~~~~~
 *                                      //.-~~~--\
 *                               神兽保佑
 *                              代码无BUG!
 * @author mazaiting
 * @date 2019-07-05
 * @decription 图虫信息列表
 */
// 忽略未知的属性
@JsonIgnoreProperties(ignoreUnknown = true)
public class WormBean implements IJsonBean {
    /**
     * 偏好列表
     */
    @JsonProperty("feedList")
    private List<FeedBean> feedList;

    public List<FeedBean> getFeedList() {
        return feedList;
    }

    public void setFeedList(List<FeedBean> feedList) {
        this.feedList = feedList;
    }

    @Override
    public String toJson() {
        return JackJsonUtil.toJson(this);
    }

    @SuppressWarnings("unchecked")
    @Override
    public WormBean fromJson(String content) {
        return JackJsonUtil.formJson(content, WormBean.class);
    }

    /**
     * 偏好
     */
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class FeedBean implements IJsonBean {

        /**
         * 文章 ID
         */
        @JsonProperty(value = "post_id")
        private int postId;

        /**
         * 文章类型
         */
        @JsonProperty(value = "type")
        private String type;

        /**
         * 作者 ID
         */
        @JsonProperty(value = "author_id")
        private String authorId;

        /**
         * 发布时间
         */
        @JsonProperty(value = "published_at")
        private String publishedAt;

        /**
         * 文章地址
         */
        @JsonProperty(value = "url")
        private String url;

        /**
         * 喜欢数
         */
        @JsonProperty(value = "favorites")
        private int favorites;

        /**
         * 评论数
         */
        @JsonProperty(value = "comments")
        private int comments;

        /**
         * 阅读次数
         */
        @JsonProperty(value = "views")
        private int views;

        /**
         * 分享
         */
        @JsonProperty(value = "shares")
        private int shares;

        /**
         * 内容
         */
        @JsonProperty(value = "content")
        private String content;

        /**
         * 标题
         */
        @JsonProperty(value = "title")
        private String title;

        /**
         * 图片数量
         */
        @JsonProperty(value = "image_count")
        private int imageCount;

        /**
         * 标签
         */
        @JsonProperty(value = "tags")
        private List<String> tags;

        /**
         * 数据类型
         */
        @JsonProperty(value = "data_type")
        private String dataType;

        /**
         * 创建时间
         */
        @JsonProperty(value = "created_at")
        private String createdAt;

        /**
         * 作者信息
         */
        @JsonProperty(value = "site")
        private SiteBean site;

        /**
         * 图片列表
         */
        @JsonProperty(value = "images")
        private List<ImageBean> images;

        public int getPostId() {
            return postId;
        }

        public void setPostId(int postId) {
            this.postId = postId;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getAuthorId() {
            return authorId;
        }

        public void setAuthorId(String authorId) {
            this.authorId = authorId;
        }

        public String getPublishedAt() {
            return publishedAt;
        }

        public void setPublishedAt(String publishedAt) {
            this.publishedAt = publishedAt;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public int getFavorites() {
            return favorites;
        }

        public void setFavorites(int favorites) {
            this.favorites = favorites;
        }

        public int getComments() {
            return comments;
        }

        public void setComments(int comments) {
            this.comments = comments;
        }

        public int getViews() {
            return views;
        }

        public void setViews(int views) {
            this.views = views;
        }

        public int getShares() {
            return shares;
        }

        public void setShares(int shares) {
            this.shares = shares;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public int getImageCount() {
            return imageCount;
        }

        public void setImageCount(int imageCount) {
            this.imageCount = imageCount;
        }

        public List<String> getTags() {
            return tags;
        }

        public void setTags(List<String> tags) {
            this.tags = tags;
        }

        public String getDataType() {
            return dataType;
        }

        public void setDataType(String dataType) {
            this.dataType = dataType;
        }

        public String getCreatedAt() {
            return createdAt;
        }

        public void setCreatedAt(String createdAt) {
            this.createdAt = createdAt;
        }

        public SiteBean getSite() {
            return site;
        }

        public void setSite(SiteBean site) {
            this.site = site;
        }

        public List<ImageBean> getImages() {
            return images;
        }

        public void setImages(List<ImageBean> images) {
            this.images = images;
        }

        @Override
        public String toJson() {
            return JackJsonUtil.toJson(this);
        }

        @SuppressWarnings("unchecked")
        @Override
        public FeedBean fromJson(String content) {
            return JackJsonUtil.formJson(content, FeedBean.class);
        }
    }

    /**
     * 图片信息
     * 图片地址: https://photo.tuchong.com/${user_id}/f/${img_id}
     */
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class ImageBean implements IJsonBean {

        /**
         * 图片 ID
         */
        @JsonProperty(value = "img_id")
        private int imgId;

        /**
         * 用户 ID
         */
        @JsonProperty(value = "user_id")
        private int userId;

        /**
         * 标题
         */
        @JsonProperty(value = "title")
        private String title;

        /**
         * 摘要
         */
        @JsonProperty(value = "excerpt")
        private String excerpt;

        /**
         * 图片宽度
         */
        @JsonProperty(value = "width")
        private int width;

        /**
         * 图片高度
         */
        @JsonProperty(value = "height")
        private int height;

        /**
         * 图片描述
         */
        @JsonProperty(value = "description")
        private String description;

        public int getImgId() {
            return imgId;
        }

        public void setImgId(int imgId) {
            this.imgId = imgId;
        }

        public int getUserId() {
            return userId;
        }

        public void setUserId(int userId) {
            this.userId = userId;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getExcerpt() {
            return excerpt;
        }

        public void setExcerpt(String excerpt) {
            this.excerpt = excerpt;
        }

        public int getWidth() {
            return width;
        }

        public void setWidth(int width) {
            this.width = width;
        }

        public int getHeight() {
            return height;
        }

        public void setHeight(int height) {
            this.height = height;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        @Override
        public String toJson() {
            return JackJsonUtil.toJson(this);
        }

        @SuppressWarnings("unchecked")
        @Override
        public ImageBean fromJson(String content) {
            return JackJsonUtil.formJson(content, ImageBean.class);
        }
    }

    /**
     * 作者信息
     */
    public static class SiteBean implements IJsonBean {

        /**
         * 作者 ID
         */
        @JsonProperty(value = "site_id")
        private String siteId;
        /**
         * 类型
         */
        @JsonProperty(value = "type")
        private String type;
        /**
         * 名字
         */
        @JsonProperty(value = "name")
        private String name;
        /**
         * 域
         */
        @JsonProperty(value = "domain")
        private String domain;
        /**
         * 描述
         */
        @JsonProperty(value = "description")
        private String description;
        /**
         * 关注
         */
        @JsonProperty(value = "followers")
        private int followers;
        /**
         * 主页
         */
        @JsonProperty(value = "url")
        private String url;
        /**
         * 头像
         */
        @JsonProperty(value = "icon")
        private String icon;
        /**
         * 是否关注
         */
        @JsonProperty(value = "is_following")
        private boolean isFollowing;

        @Override
        public String toJson() {
            return JackJsonUtil.toJson(this);
        }

        @SuppressWarnings("unchecked")
        @Override
        public SiteBean fromJson(String content) {
            return JackJsonUtil.formJson(content, SiteBean.class);
        }
    }
}
